Office 365怎么定制task form

hurryin 2018-03-08 04:27:08
Sharepoint online默认自带的审批界面太简陋了,而且不能够显示申请表单的数据,有没有什么办法可以用原生的HTML
定制task form?Info path现在客户不允许用
...全文
1041 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kianteck 2018-12-08
  • 打赏
  • 举报
回复
对于SharePoint上使用定制的Form可以使用PowerApps实现。
Steve@MS 2018-09-04
  • 打赏
  • 举报
回复
可以使用PowerApps,代码量会小很多
霖雨 版主 2018-03-12
  • 打赏
  • 举报
回复
引用 3 楼 hurryin 的回复:
[quote=引用 2 楼 霖雨的回复:]显示申请表单的数据,可以在页面上用JavaScript或者REST读取,然后进行展示,具体代码网上一搜一堆; 然后,用Jquery隐藏一些不必要的字段,应该还是可以接受的;
请问群主 我现在可以查出数据。但是如何用js怎么实现审批呢[/quote] 建议审批用默认的按钮,在上面读取工作流相关信息进行展示,会省很多工作量。 如果要用JavaScript审批,就相对复杂很多了。 参考 https://sharepoint.stackexchange.com/questions/119323/approve-listitem-task-from-button-with-javascript
hurryin 2018-03-10
  • 打赏
  • 举报
回复
引用 2 楼 霖雨的回复:
显示申请表单的数据,可以在页面上用JavaScript或者REST读取,然后进行展示,具体代码网上一搜一堆; 然后,用Jquery隐藏一些不必要的字段,应该还是可以接受的;
请问群主 我现在可以查出数据。但是如何用js怎么实现审批呢
Justin-Liu 2018-03-09
  • 打赏
  • 举报
回复
完全自定义的话,写服务放到Azure上,然后自己写审批页面(用API读取数据),然后在页面上用JS把相应的操作改成自己的链接,说得容易做起来很麻烦。 还可以用SPD直接改Form表单。 推荐用FLOW做,看起来还不错。
霖雨 版主 2018-03-09
  • 打赏
  • 举报
回复
显示申请表单的数据,可以在页面上用JavaScript或者REST读取,然后进行展示,具体代码网上一搜一堆; 然后,用Jquery隐藏一些不必要的字段,应该还是可以接受的;
Chapter 1: An Introduction to Outlook 2007 Programming 1 Setting Up Outlook VBA 1 Setting Up Macro Security 2 Creating a Code-Signing Certificate 3 Reviewing the VBA Editor Interface and Options 4 Understanding Outlook 5 Outlook Profiles and Data Store 6 Outlook Sessions and Data Stores 6 Outlook Folders 6 Outlook Items 8 Outlook Data Storage 8 Accessing Data Stores Using NameSpace 9 Accessing Data with Tables 9 Outlook Data Display 10 Summary 11 Chapter 2: What’s New in Outlook 2007 13 The Unified Object Model 14 The PropertyAccessor 14 Stores and Storage Items 24 User Interface Objects 26 Accounts 28 Performance Improvements 30 Working with Tables Instead of Items 30 Filtering Tables 31 Table Default Columns 33 Table Limitations 33 Security 34 Trusted Code 35 Untrusted Code 35 The Importance of Using DASL 35 DASL Namespaces 36 Using DASL and JET Syntax 36 Summary 38 Chapter 3: Outlook Development 39 The Application Object 39 New Methods, Properties, and Events 44 Other Important Collections, Methods, Properties, and Events 48 The NameSpace Object 53 Exchange 53 Categories 54 Picking Folders 54 Picking Names 55 Summary 57 Chapter 4: Outlook VBA 59 The Outlook VBA Project 59 The Project File 59 ThisOutlookSession 60 Macros and VBA Procedures 60 Macro Security 60 Security Levels 61 Signed Macro Code 61 Class Modules 61 ThisOutlookSession 62 User Classes 62 Code Modules 63 Office UserForms 64 Creating the Macro User Interface 64 Working with Outlook Events 68 Application Events 69 Folder Events 77 User Events 80 Wrapper Classes and Collections 81 Macro Projects 88 Custom Rules 89 Additional Macros 100 Running and Distributing Macros 108 Running Macros 108 Distributing the VBA Project 109 Distributing Individual Macros 110 Summary 110 Chapter 5: Outlook Forms 111 Working with Standard Forms 111 Forms Libraries 112 Published Forms 113 Form Customization 113 Advantages and Disadvantages of Custom Forms 114 Back to the Past: the Forms Development Environment 116 Using the Field Chooser 118 Using the Control Toolbox 119 Using the Code Window 120 Prototyping Forms Code in VBA 122 Simulating the Form Environment in VBA 123 Developing and Debugging Using VBA 124 Custom Form Walkthrough 124 Creating, Publishing, and Running a Form 125 Where to Publish Forms 129 Publishing Forms Using Code 129 Testing Code for the Form 132 Forms Management 136 Form Behavior 138 Trusted Forms 138 Active X Controls 138 Script in Forms 139 Form Regions 139 Form Region Locations, Properties, and Registry Settings 140 Form Region Walkthrough 141 Summary 145 Chapter 6: COM Addins 147 Managed or Unmanaged Code? 147 IDTExtensibility2 and Trusted COM Addins 148 Version Differences 149 VB.NET Addin Implementations 149 C# Addin Implementations 150 Addin Templates 151 Explorer and Inspector Event Handlers 152 Setting Up Explorer and Inspector Event Handlers 152 The OnDisconnection Catch-22 Bug 155 Explorer and Inspector Wrappers 164 Template Utility Code 179 VB.NET Utility Code 180 C# Utility Code 182 Displaying Outlook Property Pages 185 Displaying Property Pages with VB.NET 185 Displaying Property Pages with C# 186 Communicating with a COM Addin 188 VB.NET 188 Testing Addin Communications 189 C# 190 VSTO with VB.NET 191 VSTO with C# 194 Summary 196 Chapter 7: COM Addins and the Outlook User Interface 197 Working with Menus and Toolbars 197 Menus and Toolbars in Explorers 198 VB.NET 199 C# 206 VSTO Interface Handlers 213 VB.NET 213 C# 214 AxHost 216 VB.NET 216 C# 216 Working with the Ribbon 217 Ribbon XML 218 Ribbon Callbacks 224 Custom Task Panes 234 Creating Custom Task Panes 235 Working with Custom Task Panes 239 Form Regions 240 Creating Custom Form Regions 242 Working with Custom Form Regions 244 Custom Views 248 Types of Custom Views 248 Creating Custom Views 248 Filtering and Formatting Custom Views 249 View XML 250 Summary 251 Chapter 8: Interfacing Outlook with Other Applications 253 Microsoft Word 254 Microsoft Excel 257 Microsoft Access 264 ADO 265 Access DAO 267 DAO DBEngine 268 Web Browser 269 Browser Control Form 269 Summary 272 Chapter 9: Real-World Outlook Programming 275 Supporting Multiple Versions of Outlook 275 Coding for Compatibility 276 Ribbon Considerations and Workarounds 277 Addin Deployment 279 Unmanaged Code Addins 279 Managed Code Addins 280 Outlook Programming Limitations 282 Outlook 2007 282 Outlook 2003 and Earlier 283 Things We Still Don’t Have in Outlook 2007 287 Using Alternate APIs 288 CDO 288 Redemption 289 Summary 303 Chapter 10: Task Management System 305 Task Management System Features 305 The Connect Class 307 The VB Connect Class 307 The C# Connect Class 319 C# MyAxHost 335 VB Globals 337 VB OutExpl 337 C# OutExpl 338 VB ExplWrap 340 C# ExplWrap 341 VB OutInsp 344 C# OutInsp 345 VB InspWrap 347 C# InspWrap 353 VB TaskPane 362 C# TaskPane 366 VB Ribbon XML 372 C# Ribbon XML 373 Summary 373 Appendix A: Outlook 2007 Object Model Summary 375 Appendix B: Troubleshooting Problems and Support 425 Index 439
Chapter 1: An Introduction to Outlook 2007 Programming 1 Setting Up Outlook VBA 1 Setting Up Macro Security 2 Creating a Code-Signing Certificate 3 Reviewing the VBA Editor Interface and Options 4 Understanding Outlook 5 Outlook Profiles and Data Store 6 Outlook Sessions and Data Stores 6 Outlook Folders 6 Outlook Items 8 Outlook Data Storage 8 Accessing Data Stores Using NameSpace 9 Accessing Data with Tables 9 Outlook Data Display 10 Summary 11 Chapter 2: What’s New in Outlook 2007 13 The Unified Object Model 14 The PropertyAccessor 14 Stores and Storage Items 24 User Interface Objects 26 Accounts 28 Performance Improvements 30 Working with Tables Instead of Items 30 Filtering Tables 31 Table Default Columns 33 Table Limitations 33 Security 34 Trusted Code 35 Untrusted Code 35 The Importance of Using DASL 35 DASL Namespaces 36 Using DASL and JET Syntax 36 Summary 38 Chapter 3: Outlook Development 39 The Application Object 39 New Methods, Properties, and Events 44 Other Important Collections, Methods, Properties, and Events 48 The NameSpace Object 53 Exchange 53 Categories 54 Picking Folders 54 Picking Names 55 Summary 57 Chapter 4: Outlook VBA 59 The Outlook VBA Project 59 The Project File 59 ThisOutlookSession 60 Macros and VBA Procedures 60 Macro Security 60 Security Levels 61 Signed Macro Code 61 Class Modules 61 ThisOutlookSession 62 User Classes 62 Code Modules 63 Office UserForms 64 Creating the Macro User Interface 64 Working with Outlook Events 68 Application Events 69 Folder Events 77 User Events 80 Wrapper Classes and Collections 81 Macro Projects 88 Custom Rules 89 Additional Macros 100 Running and Distributing Macros 108 Running Macros 108 Distributing the VBA Project 109 Distributing Individual Macros 110 Summary 110 Chapter 5: Outlook Forms 111 Working with Standard Forms 111 Forms Libraries 112 Published Forms 113 Form Customization 113 Advantages and Disadvantages of Custom Forms 114 Back to the Past: the Forms Development Environment 116 Using the Field Chooser 118 Using the Control Toolbox 119 Using the Code Window 120 Prototyping Forms Code in VBA 122 Simulating the Form Environment in VBA 123 Developing and Debugging Using VBA 124 Custom Form Walkthrough 124 Creating, Publishing, and Running a Form 125 Where to Publish Forms 129 Publishing Forms Using Code 129 Testing Code for the Form 132 Forms Management 136 Form Behavior 138 Trusted Forms 138 Active X Controls 138 Script in Forms 139 Form Regions 139 Form Region Locations, Properties, and Registry Settings 140 Form Region Walkthrough 141 Summary 145 Chapter 6: COM Addins 147 Managed or Unmanaged Code? 147 IDTExtensibility2 and Trusted COM Addins 148 Version Differences 149 VB.NET Addin Implementations 149 C# Addin Implementations 150 Addin Templates 151 Explorer and Inspector Event Handlers 152 Setting Up Explorer and Inspector Event Handlers 152 The OnDisconnection Catch-22 Bug 155 Explorer and Inspector Wrappers 164 Template Utility Code 179 VB.NET Utility Code 180 C# Utility Code 182 Displaying Outlook Property Pages 185 Displaying Property Pages with VB.NET 185 Displaying Property Pages with C# 186 Communicating with a COM Addin 188 VB.NET 188 Testing Addin Communications 189 C# 190 VSTO with VB.NET 191 VSTO with C# 194 Summary 196 Chapter 7: COM Addins and the Outlook User Interface 197 Working with Menus and Toolbars 197 Menus and Toolbars in Explorers 198 VB.NET 199 C# 206 VSTO Interface Handlers 213 VB.NET 213 C# 214 AxHost 216 VB.NET 216 C# 216 Working with the Ribbon 217 Ribbon XML 218 Ribbon Callbacks 224 Custom Task Panes 234 Creating Custom Task Panes 235 Working with Custom Task Panes 239 Form Regions 240 Creating Custom Form Regions 242 Working with Custom Form Regions 244 Custom Views 248 Types of Custom Views 248 Creating Custom Views 248 Filtering and Formatting Custom Views 249 View XML 250 Summary 251 Chapter 8: Interfacing Outlook with Other Applications 253 Microsoft Word 254 Microsoft Excel 257 Microsoft Access 264 ADO 265 Access DAO 267 DAO DBEngine 268 Web Browser 269 Browser Control Form 269 Summary 272 Chapter 9: Real-World Outlook Programming 275 Supporting Multiple Versions of Outlook 275 Coding for Compatibility 276 Ribbon Considerations and Workarounds 277 Addin Deployment 279 Unmanaged Code Addins 279 Managed Code Addins 280 Outlook Programming Limitations 282 Outlook 2007 282 Outlook 2003 and Earlier 283 Things We Still Don’t Have in Outlook 2007 287 Using Alternate APIs 288 CDO 288 Redemption 289 Summary 303 Chapter 10: Task Management System 305 Task Management System Features 305 The Connect Class 307 The VB Connect Class 307 The C# Connect Class 319 C# MyAxHost 335 VB Globals 337 VB OutExpl 337 C# OutExpl 338 VB ExplWrap 340 C# ExplWrap 341 VB OutInsp 344 C# OutInsp 345 VB InspWrap 347 C# InspWrap 353 VB TaskPane 362 C# TaskPane 366 VB Ribbon XML 372 C# Ribbon XML 373 Summary 373 Appendix A: Outlook 2007 Object Model Summary 375 Appendix B: Troubleshooting Problems and Support 425 Index 439
Fundamentals of the JavaMail API Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Table of Contents If you're viewing this document online, you can click any of the topics below to link directly to that section. 1. Tutorial tips 2 2. Introducing the JavaMail API 3 3. Reviewing related protocols 4 4. Installing JavaMail 6 5. Reviewing the core classes 8 6. Using the JavaMail API 13 7. Searching with SearchTerm 21 8. Exercises 22 9. Wrapup 32 Fundamentals of the JavaMail API Page 1 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Section 1. Tutorial tips Should I take this tutorial? Looking to incorporate mail facilities into your platform-independent Java solutions? Look no further than the JavaMail API, which offers a protocol-independent model for working with IMAP, POP, SMTP, MIME, and all those other Internet-related messaging protocols. With the help of the JavaBeans Activation Framework (JAF), your applications can now be mail-enabled through the JavaMail API. Concepts After completing this module you will understand the: * Basics of the Internet mail protocols SMTP, POP3, IMAP, and MIME * Architecture of the JavaMail framework * Connections between the JavaMail API and the JavaBeans Activation Framework Objectives By the end of this module you will be able to: * Send and read mail using the JavaMail API * Deal with sending and receiving attachments * Work with HTML messages * Use search terms to search for messages Prerequisites Instructions on how to download and install the JavaMail API are contained in the course. In addition, you will need a development environment such as the JDK 1.1.6+ or the Java 2 Platform, Standard Edition (J2SE) 1.2.x or 1.3.x. A general familiarity with object-oriented programming concepts and the Java programming language is necessary. The Java language essentials tutorial can help. copyright 1996-2000 Magelang Institute dba jGuru Contact jGuru has been dedicated to promoting the growth of the Java technology community through evangelism, education, and software since 1995. You can find out more about their activities, including their huge collection of FAQs at jGuru.com . To send feedback to jGuru about this course, send mail to producer@jguru.com . Course author: Formerly with jGuru.com , John Zukowski does strategic Java consulting for JZ Ventures, Inc. His latest book is titled Java Collections from Apress . Fundamentals of the JavaMail API Page 2 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Section 2. Introducing the JavaMail API What is the JavaMail API? The JavaMail API is an optional package (standard extension) for reading, composing, and sending electronic messages. You use the package to create Mail User Agent (MUA) type programs, similar to Eudora, pine, and Microsoft Outlook. The API's main purpose is not for transporting, delivering, and forwarding messages; this is the purview of applications such as sendmail and other Mail Transfer Agent (MTA) type programs. MUA-type programs let users read and write e-mail, whereas MUAs rely on MTAs to handle the actual delivery. The JavaMail API is designed to provide protocol-independent access for sending and receiving messages by dividing the API into two parts: * The first part of the API is the focus of this course --basically, how to send and receive messages independent of the provider/protocol. * The second part speaks the protocol-specific languages, like SMTP, POP, IMAP, and NNTP. With the JavaMail API, in order to communicate with a server, you need a provider for a protocol. The creation of protocol-specific providers is not covered in this course because Sun provides a sufficient set for free. Fundamentals of the JavaMail API Page 3 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Section 3. Reviewing related protocols Introduction Before looking into the JavaMail API specifics, let's step back and take a look at the protocols used with the API. There are basically four that you'll come to know and love: * SMTP * POP * IMAP * MIME You will also run across NNTP and some others. Understanding the basics of all the protocols will help you understand how to use the JavaMail API. While the API is designed to be protocol agnostic, you can't overcome the limitations of the underlying protocols. If a capability isn't supported by a chosen protocol, the JavaMail API doesn't magically add the capability on top of it. (As you'll soon see, this can be a problem when working with POP.) SMTP The Simple Mail Transfer Protocol (SMTP) is defined by RFC 821 . It defines the mechanism for delivery of e-mail. In the context of the JavaMail API, your JavaMail-based program will communicate with your company or Internet Service Provider's (ISP's) SMTP server. That SMTP server will relay the message on to the SMTP server of the recipient(s) to eventually be acquired by the user(s) through POP or IMAP. This does not require your SMTP server to be an open relay, as authentication is supported, but it is your responsibility to ensure the SMTP server is configured properly. There is nothing in the JavaMail API for tasks like configuring a server to relay messages or to add and remove e-mail accounts. POP POP stands for Post Office Protocol. Currently in version 3, also known as POP3, RFC 1939 defines this protocol. POP is the mechanism most people on the Internet use to get their mail. It defines support for a single mailbox for each user. That is all it does, and that is also the source of a lot of confusion. Much of what people are familiar with when using POP, like the ability to see how many new mail messages they have, are not supported by POP at all. These capabilities are built into programs like Eudora or Microsoft Outlook, which remember things like the last mail received and calculate how many are new for you. So, when using the JavaMail API, if you want this type of information, you have to calculate it yourself. IMAP IMAP is a more advanced protocol for receiving messages. Defined in RFC 2060 , IMAP stands for Internet Message Access Protocol, and is currently in version 4, also known as IMAP4. When using IMAP, your mail server must support the protocol. You can't just change your program to use IMAP instead of POP and expect everything in IMAP to be supported. Assuming your mail server supports IMAP, your JavaMail-based program can take Fundamentals of the JavaMail API Page 4 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks advantage of users having multiple folders on the server and these folders can be shared by multiple users. Due to the more advanced capabilities, you might think IMAP would be used by everyone. It isn't. It places a much heavier burden on the mail server, requiring the server to receive the new messages, deliver them to users when requested, and maintain them in multiple folders for each user. While this does centralize backups, as users' long-term mail folders get larger and larger, everyone suffers when disk space is exhausted. With POP, saved messages get offloaded from the mail server. MIME MIME stands for Multipurpose Internet Mail Extensions. It is not a mail transfer protocol. Instead, it defines the content of what is transferred: the format of the messages, attachments, and so on. There are many different documents that take effect here: RFC 822 , RFC 2045 , RFC 2046 , and RFC 2047 . As a user of the JavaMail API, you usually don't need to worry about these formats. However, these formats do exist and are used by your programs. NNTP and others Because of the split of the JavaMail API between provider and everything else, you can easily add support for additional protocols. Sun maintains a list of third-party providers that take advantage of protocols for which Sun does not provide out-of-the-box support. You'll find support for NNTP (Network News Transport Protocol) [newsgroups], S/MIME (Secure Multipurpose Internet Mail Extensions), and more. Fundamentals of the JavaMail API Page 5 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Section 4. Installing JavaMail Introduction There are two versions of the JavaMail API commonly used today: 1.2 and 1.1.3. All the examples in this course will work with both. While 1.2 is the latest, 1.1.3 is the version included with the 1.2.1 version of the Java 2 Platform, Enterprise Edition (J2EE), so it is still commonly used. The version of the JavaMail API you want to use affects what you download and install. All will work with JDK 1.1.6+, Java 2 Platform, Standard Edition (J2SE) version 1.2.x, and J2SE version 1.3.x. Note: After installing Sun's JavaMail implementation, you can find many example programs in the demo directory. Installing JavaMail 1.2 To use the JavaMail 1.2 API, download the JavaMail 1.2 implementation, unbundle the javamail-1_2.zip file, and add the mail.jar file to your CLASSPATH. The 1.2 implementation comes with an SMTP, IMAP4, and POP3 provider besides the core classes. After installing JavaMail 1.2, install the JavaBeans Activation Framework. Installing JavaMail 1.1.3 To use the JavaMail 1.1.3 API, download the JavaMail 1.1.3 implementation, unbundle the javamail1_1_3.zip file, and add the mail.jar file to your CLASSPATH. The 1.1.3 implementation comes with an SMTP and IMAP4 provider, besides the core classes. If you want to access a POP server with JavaMail 1.1.3, download and install a POP3 provider. Sun has one available separate from the JavaMail implementation. After downloading and unbundling pop31_1_1.zip, add pop3.jar to your CLASSPATH, too. After installing JavaMail 1.1.3, install the JavaBeans Activation Framework. Installing the JavaBeans Activation Framework All versions of the JavaMail API require the JavaBeans Activation Framework. The framework adds support for typing arbitrary blocks of data and handling it accordingly. This doesn't sound like much, but it is your basic MIME-type support found in many browsers and mail tools today. After downloading the framework, unbundle the jaf1_0_1.zip file, and add the activation.jar file to your CLASSPATH. For JavaMail 1.2 users, you should now have added mail.jar and activation.jar to your CLASSPATH. For JavaMail 1.1.3 users, you should now have added mail.jar, pop3.jar, and activation.jar to your CLASSPATH. If you have no plans of using POP3, you don't Fundamentals of the JavaMail API Page 6 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks need to add pop3.jar to your CLASSPATH. If you don't want to change the CLASSPATH environment variable, copy the jar files to your lib/ext directory under the Java Runtime Environment (JRE) directory. For instance, for the J2SE 1.3 release, the default directory would be C:\jdk1.3\jre\lib\ext on a Windows platform. Using JavaMail with the Java 2 Enterprise Edition If you use J2EE, there is nothing special you have to do to use the basic JavaMail API; it comes with the J2EE classes. Just make sure the j2ee.jar file is in your CLASSPATH and you're all set. For J2EE 1.2.1, the POP3 provider comes separately, so download and follow the steps to include the POP3 provider as shown in the previous section "Installing JavaMail 1.1.3." J2EE 1.3 users get the POP3 provider with J2EE so do not require the separate installation. Neither installation requires you to install the JavaBeans Activation Framework. Exercise Exercise 1. How to set up a JavaMail environment on page 22 Fundamentals of the JavaMail API Page 7 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Section 5. Reviewing the core classes Introduction Before taking a how-to approach at looking at the JavaMail classes in depth, this section walks you through the core classes that make up the API: Session, Message, Address, Authenticator, Transport, Store, and Folder. All these classes are found in the top-level package for the JavaMail API, javax.mail, though you'll frequently find yourself using subclasses found in the javax.mail.internet package. Session The Session class defines a basic mail session. It is through this session that everything else works. The Session object takes advantage of a java.util.Properties object to get information like mail server, username, password, and other information that can be shared across your entire application. The constructors for the class are private. You can get a single default session that can be shared with the getDefaultInstance() method: Properties props = new Properties(); // fill props with any information Session session = Session.getDefaultInstance(props, null); Or, you can create a unique session with getInstance(): Properties props = new Properties(); // fill props with any information Session session = Session.getDefaultInstance(props, null); In both cases, the null argument is an Authenticator object that is not being used at this time. In most cases, it is sufficient to use the shared session, even if working with mail sessions for multiple user mailboxes. You can add the username and password combination in at a later step in the communication process, keeping everything separate. Message Once you have your Session object, it is time to move on to creating the message to send. This is done with a type of Message . Because Message is an abstract class, you must work with a subclass, in most cases javax.mail.internet.MimeMessage .A MimeMessage is an e-mail message that understands MIME types and headers, as defined in the different RFCs. Message headers are restricted to US-ASCII characters only, though non-ASCII characters can be encoded in certain header fields. To create a Message, pass along the Session object to the MimeMessage constructor: MimeMessage message = new MimeMessage(session); Fundamentals of the JavaMail API Page 8 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Note: There are other constructors, like for creating messages from RFC822-formatted input streams. Once you have your message, you can set its parts, as Message implements the Part interface (with MimeMessage implementing MimePart ). The basic mechanism to set the content is the setContent() method, with arguments for the content and the mime type: message.setContent("Hello", "text/plain"); If, however, you know you are working with a MimeMessage and your message is plain text, you can use its setText() method, which only requires the actual content, defaulting to the MIME type of text/plain: message.setText("Hello"); For plain text messages, the latter form is the preferred mechanism to set the content. For sending other kinds of messages, like HTML messages, use the former. For setting the subject, use the setSubject() method: message.setSubject("First"); Address Once you've created the Session and the Message, as well as filled the message with content, it is time to address your letter with an Address . Like Message, Address is an abstract class. You use the javax.mail.internet.InternetAddress class. To create an address with just the e-mail address, pass the e-mail address to the constructor: Address address = new InternetAddress("president@whitehouse.gov"); If you want a name to appear next to the e-mail address, you can pass that along to the constructor, too: Address address = new InternetAddress("president@whitehouse.gov", "George Bush"); You will need to create address objects for the message's from field as well as the to field. Unless your mail server prevents you, there is nothing stopping you from sending a message that appears to be from anyone. Once you've created the addresses, you connect them to a message in one of two ways. For identifying the sender, you use the setFrom() and setReplyTo() methods. message.setFrom(address) If your message needs to show multiple from addresses, use the addFrom() method: Fundamentals of the JavaMail API Page 9 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Address address[] = ...; message.addFrom(address); For identifying the message recipients, you use the addRecipient() method. This method requires a Message.RecipientType besides the address. message.addRecipient(type, address) The three predefined types of address are: * Message.RecipientType.TO * Message.RecipientType.CC * Message.RecipientType.BCC So, if the message was to go to the vice president, sending a carbon copy to the first lady, the following would be appropriate: Address toAddress = new InternetAddress("vice.president@whitehouse.gov"); Address ccAddress = new InternetAddress("first.lady@whitehouse.gov"); message.addRecipient(Message.RecipientType.TO, toAddress); message.addRecipient(Message.RecipientType.CC, ccAddress); The JavaMail API provides no mechanism to check for the validity of an e-mail address. While you can program in support to scan for valid characters (as defined by RFC 822) or verify the MX (mail exchange) record yourself, these are all beyond the scope of the JavaMail API. Authenticator Like the java.net classes, the JavaMail API can take advantage of an Authenticator to access protected resources via a username and password. For the JavaMail API, that resource is the mail server. The JavaMail Authenticator is found in the javax.mail package and is different from the java.net class of the same name. The two don't share the same Authenticator as the JavaMail API works with Java 1.1, which didn't have the java.net variety. To use the Authenticator, you subclass the abstract class and return a PasswordAuthentication instance from the getPasswordAuthentication() method. You must register the Authenticator with the session when created. Then, your Authenticator will be notified when authentication is necessary. You could pop up a window or read the username and password from a configuration file (though if not encrypted is not secure), returning them to the caller as a PasswordAuthentication object. Properties props = new Properties(); // fill props with any information Authenticator auth = new MyAuthenticator(); Session session = Session.getDefaultInstance(props, auth); Transport The final part of sending a message is to use the Transport class. This class speaks the Fundamentals of the JavaMail API Page 10 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks protocol-specific language for sending the message (usually SMTP). It's an abstract class and works something like Session. You can use the default version of the class by just calling the static send() method: Transport.send(message); Or, you can get a specific instance from the session for your protocol, pass along the username and password (blank if unnecessary), send the message, and close the connection: message.saveChanges(); // implicit with send() Transport transport = session.getTransport("smtp"); transport.connect(host, username, password); transport.sendMessage(message, message.getAllRecipients()); transport.close(); This latter way is best when you need to send multiple messages, as it will keep the connection with the mail server active between messages. The basic send() mechanism makes a separate connection to the server for each method call. Note: To watch the mail commands go by to the mail server, set the debug flag with session.setDebug(true). Store and folder Getting messages starts similarly to sending messages with a Session. However, after getting the session, you connect to a Store , quite possibly with a username and password or Authenticator. Like Transport, you tell the Store what protocol to use: // Store store = session.getStore("imap"); Store store = session.getStore("pop3"); store.connect(host, username, password); After connecting to the Store, you can then get a Folder , which must be opened before you can read messages from it: Folder folder = store.getFolder("INBOX"); folder.open(Folder.READ_ONLY); Message message[] = folder.getMessages(); For POP3, the only folder available is the INBOX. If you are using IMAP, you can have other folders available. Note: Sun's providers are meant to be smart. While Message message[] = folder.getMessages(); might look like a slow operation reading every message from the server, only when you actually need to get a part of the message is the message content retrieved. Once you have a Message to read, you can get its content with getContent() or write its content to a stream with writeTo(). The getContent() method only gets the message content, while writeTo() output includes headers. Fundamentals of the JavaMail API Page 11 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks System.out.println(((MimeMessage)message).getContent()); Once you're done reading mail, close the connection to the folder and store. folder.close(aBoolean); store.close(); The boolean passed to the close() method of folder states whether or not to update the folder by removing deleted messages. Moving on Essentially, understanding how to use these seven classes is all you need for nearly everything with the JavaMail API. Most of the other capabilities of the JavaMail API build off these seven classes to do something a little different or in a particular way, like if the content is an attachment. Certain tasks, like searching, are isolated and are discussed later. Fundamentals of the JavaMail API Page 12 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Section 6. Using the JavaMail API Introduction You've seen how to work with the core parts of the JavaMail API. In the following sections you'll find a how-to approach for connecting the pieces to do specific tasks. Sending messages Sending an e-mail message involves getting a session, creating and filling a message, and sending it. You can specify your SMTP server by setting the mail.smtp.host property for the Properties object passed when getting the Session: String host = ...; String from = ...; String to = ...; // Get system properties Properties props = System.getProperties(); // Setup mail server props.put("mail.smtp.host", host); // Get session Session session = Session.getDefaultInstance(props, null); // Define message MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setSubject("Hello JavaMail"); message.setText("Welcome to JavaMail"); // Send message Transport.send(message); You should place the code in a try-catch block, as setting up the message and sending it can throw exceptions. Exercise: Exercise 2. How to send your first message on page 23 Fetching messages For reading mail, you get a session, get and connect to an appropriate store for your mailbox, open the appropriate folder, and get your messages. Also, don't forget to close the connection when done. String host = ...; String username = ...; String password = ...; // Create empty properties Properties props = new Properties(); // Get session Session session = Session.getDefaultInstance(props, null); Fundamentals of the JavaMail API Page 13 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks // Get the store Store store = session.getStore("pop3"); store.connect(host, username, password); // Get folder Folder folder = store.getFolder("INBOX"); folder.open(Folder.READ_ONLY); // Get directory Message message[] = folder.getMessages(); for (int i=0, n=message.length; itask but a task built into mail clients. To find out what flags are supported, ask the folder with getPermanentFlags(). To delete messages, you set the message's DELETED flag: message.setFlag(Flags.Flag.DELETED, true); Open up the folder in READ_WRITE mode first though: folder.open(Folder.READ_WRITE); Then, when you are done processing all messages, close the folder, passing in a true value to expunge the deleted messages. folder.close(true); There is an expunge() method of Folder that can be used to delete the messages. However, it doesn't work for Sun's POP3 provider. Other providers may or may not implement the capabilities. It will more than likely be implemented for IMAP providers. Because POP only supports single access to the mailbox, you have to close the folder to delete the messages with Sun's provider. To unset a flag, just pass false to the setFlag() method. To see if a flag is set, check it with isSet(). Authenticating yourself You learned that you can use an Authenticator to prompt for username and password when needed, instead of passing them in as strings. Here you'll actually see how to more fully use authentication. Instead of connecting to the Store with the host, username, and password, you configure the Properties to have the host, and tell the Session about your custom Authenticator instance, as shown here: // Setup properties Properties props = System.getProperties(); props.put("mail.pop3.host", host); // Setup authentication, get session Authenticator auth = new PopupAuthenticator(); Session session = Session.getDefaultInstance(props, auth); // Get the store Store store = session.getStore("pop3"); store.connect(); You then subclass Authenticator and return a PasswordAuthentication object from the getPasswordAuthentication() method. The following is one such implementation, with a single field for both. (This isn't a Project Swing tutorial; just enter the two parts in the one field, separated by a comma.) Fundamentals of the JavaMail API Page 15 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks import javax.mail.*; import javax.swing.*; import java.util.*; public class PopupAuthenticator extends Authenticator { public PasswordAuthentication getPasswordAuthentication() { String username, password; String result = JOptionPane.showInputDialog( "Enter 'username,password'"); StringTokenizer st = new StringTokenizer(result, ","); username = st.nextToken(); password = st.nextToken(); return new PasswordAuthentication(username, password); } } Because the PopupAuthenticator relies on Swing, it will start up the event-handling thread for AWT. This basically requires you to add a call to System.exit() in your code to stop the program. Replying to messages The Message class includes a reply() method to configure a new Message with the proper recipient and subject, adding "Re: " if not already there. This does not add any content to the message, only copying the from or reply-to header to the new recipient. The method takes a boolean parameter indicating whether to reply to only the sender (false) or reply to all (true). MimeMessage reply = (MimeMessage)message.reply(false); reply.setFrom(new InternetAddress("president@whitehouse.gov")); reply.setText("Thanks"); Transport.send(reply); To configure the reply-to address when sending a message, use the setReplyTo() method. Exercise: Exercise 4. How to reply to mail on page 27 Forwarding messages Forwarding messages is a little more involved. There is no single method to call, and you build up the message to forward by working with the parts that make up a message. A mail message can be made up of multiple parts. Each part is a BodyPart , or more specifically, a MimeBodyPart when working with MIME messages. The different body parts get combined into a container called Multipart or, again, more specifically a MimeMultipart . To forward a message, you create one part for the text of your message and a second part with the message to forward, and combine the two into a multipart. Then you add the multipart to a properly addressed message and send it. That's essentially it. To copy the content from one message to another, just copy over its Fundamentals of the JavaMail API Page 16 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks DataHandler , a class from the JavaBeans Activation Framework. // Create the message to forward Message forward = new MimeMessage(session); // Fill in header forward.setSubject("Fwd: " + message.getSubject()); forward.setFrom(new InternetAddress(from)); forward.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); // Create your new message part BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setText( "Here you go with the original message:\n\n"); // Create a multi-part to combine the parts Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); // Create and fill part for the forwarded content messageBodyPart = new MimeBodyPart(); messageBodyPart.setDataHandler(message.getDataHandler()); // Add part to multi part multipart.addBodyPart(messageBodyPart); // Associate multi-part with message forward.setContent(multipart); // Send message Transport.send(forward); Working with attachments Attachments are resources associated with a mail message, usually kept outside of the message like a text file, spreadsheet, or image. As with common mail programs like Eudora and pine, you can attach resources to your mail message with the JavaMail API and get those attachments when you receive the message. Sending attachments: Sending attachments is quite like forwarding messages. You build up the parts to make the complete message. After the first part, your message text, you add other parts where the DataHandler for each is your attachment, instead of the shared handler in the case of a forwarded message. If you are reading the attachment from a file, your attachment data source is a FileDataSource . Reading from a URL, it is a URLDataSource . Once you have your DataSource, just pass it on to the DataHandler constructor, before finally attaching it to the BodyPart with setDataHandler(). Assuming you want to retain the original filename for the attachment, the last thing to do is to set the filename associated with the attachment with the setFileName() method of BodyPart. All this is shown here: // Define message Message message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setSubject("Hello JavaMail Attachment"); // Create the message part BodyPart messageBodyPart = new MimeBodyPart(); // Fill the message messageBodyPart.setText("Pardon Ideas"); Fundamentals of the JavaMail API Page 17 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); // Part two is attachment messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(filename); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename); multipart.addBodyPart(messageBodyPart); // Put parts in message message.setContent(multipart); // Send the message Transport.send(message); When including attachments with your messages, if your program is a servlet, your users must upload the attachment besides telling you where to send the message. Uploading each file can be handled with a form encoding type of multipart/form-data. <FORM ENCTYPE="multipart/form-data" method=post action="/myservlet"> FORM> Note: Message size is limited by your SMTP server, not the JavaMail API. If you run into problems, consider increasing the Java heap size by setting the ms and mx parameters. Exercise: Exercise 5. How to send attachments on page 28 Getting attachments: Getting attachments out of your messages is a little more involved then sending them because MIME has no simple notion of attachments. The content of your message is a Multipart object when it has attachments. You then need to process each Part, to get the main content and the attachment(s). Parts marked with a disposition of Part.ATTACHMENT from part.getDisposition() are clearly attachments. However, attachments can also come across with no disposition (and a non-text MIME type) or a disposition of Part.INLINE. When the disposition is either Part.ATTACHMENT or Part.INLINE, you can save off the content for that message part. Just get the original filename with getFileName() and the input stream with getInputStream(). Multipart mp = (Multipart)message.getContent(); for (int i=0, n=multipart.getCount(); i"; message.setContent(htmlText, "text/html")); On the receiving end, if you fetch the message with the JavaMail API, there is nothing built into the API to display the message as HTML. The JavaMail API only sees it as a stream of bytes. To display the message as HTML, you must either use the Swing JEditorPane or some third-party HTML viewer component. if (message.getContentType().equals("text/html")) { String content = (String)message.getContent(); JFrame frame = new JFrame(); JEditorPane text = new JEditorPane("text/html", content); text.setEditable(false); JScrollPane pane = new JScrollPane(text); frame.getContentPane().add(pane); frame.setSize(300, 300); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.show(); } Including images with your messages: On the other hand, if you want your HTML content message to be complete, with embedded images included as part of the message, you must treat the image as an attachment and reference the image with a special cid URL, where the cid is a reference to the Content-ID header of the image attachment. The process of embedding an image is quite similar to attaching a file to a message, the only Fundamentals of the JavaMail API Page 19 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks difference is you have to tell the MimeMultipart that the parts are related by setting its subtype in the constructor (or with setSubType()) and set the Content-ID header for the image to a random string which is used as the src for the image in the img tag. The following demonstrates this completely. String file = ...; // Create the message Message message = new MimeMessage(session); // Fill its headers message.setSubject("Embedded Image"); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); // Create your new message part BodyPart messageBodyPart = new MimeBodyPart(); String htmlText = "

Hello

" + ""; messageBodyPart.setContent(htmlText, "text/html"); // Create a related multi-part to combine the parts MimeMultipart multipart = new MimeMultipart("related"); multipart.addBodyPart(messageBodyPart); // Create part for the image messageBodyPart = new MimeBodyPart(); // Fetch the image and associate to part DataSource fds = new FileDataSource(file); messageBodyPart.setDataHandler(new DataHandler(fds)); messageBodyPart.setHeader("Content-ID","memememe"); // Add part to multi-part multipart.addBodyPart(messageBodyPart); // Associate multi-part with message message.setContent(multipart); Exercise: Exercise 6. How to send HTML messages with images on page 29 Fundamentals of the JavaMail API Page 20 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Section 7. Searching with SearchTerm Introduction The JavaMail API includes a filtering mechanism found in the javax.mail.search package to build up a SearchTerm . Once built, you then ask a Folder what messages match, retrieving an array of Message objects: SearchTerm st = ...; Message[] msgs = folder.search(st); There are 22 different classes available to help you build a search term. * AND terms (class AndTerm) * OR terms (class OrTerm) * NOT terms (class NotTerm) * SENT DATE terms (class SentDateTerm) * CONTENT terms (class BodyTerm) * HEADER terms (FromTerm / FromStringTerm, RecipientTerm / RecipientStringTerm, SubjectTerm, etc..) Essentially, you build up a logical expression for matching messages, then search. For instance the following term searches for messages with a (partial) subject string of ADV or a from field of friend@public.com. You might consider periodically running this query and automatically deleting any messages returned. SearchTerm st = new OrTerm( new SubjectTerm("ADV:"), new FromStringTerm("friend@public.com")); Message[] msgs = folder.search(st); Fundamentals of the JavaMail API Page 21 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Section 8. Exercises About the exercises These exercises are designed to provide help according to your needs. For example, you might simply complete the exercise given the information and the task list in the exercise body; you might want a few hints; or you may want a step-by-step guide to successfully complete a particular exercise. You can use as much or as little help as you need per exercise. Moreover, because complete solutions are also provided, you can skip a few exercises and still be able to complete future exercises requiring the skipped ones. Each exercise has a list of any prerequisite exercises, a list of skeleton code for you to start with, links to necessary API pages, and a text description of the exercise goal. In addition, there is help for each task and a solutions page with links to files that comprise a solution to the exercise. Exercise 1. How to set up a JavaMail environment In this exercise you will install Sun's JavaMail reference implementation. After installing, you will be introduced to the demonstration programs that come with the reference implementation. Task 1: Download the latest version of the JavaMail API implementation from Sun. Task 2: Download the latest version of the JavaBeans Activation Framework from Sun. Task 3: Unzip the downloaded packages. You get a ZIP file for all platforms for both packages. Help for task 3: You can use the jar tool to unzip the packages. Task 4: Add the mail.jar file from the JavaMail 1.2 download and the activation.jar file from the JavaBeans Activation Framework download to your CLASSPATH. Help for task 4: Copy the files to your extension library directory. For Microsoft Windows, using the default installation copy, the command might look like the following: cd \javamail-1.2 copy mail.jar \jdk1.3\jre\lib\ext cd \jaf-1.0.1 copy activation.jar \jdk1.3\jre\lib\ext If you don't like copying the files to the extension library directory, detailed instructions are available from Sun for setting your CLASSPATH on Windows NT. Task 5: Go into the demo directory that comes with the JavaMail API implementation and compile the msgsend program to send a test message. Help for task 5: javac msgsend.java Fundamentals of the JavaMail API Page 22 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Task 6: Execute the program passing in a from address with the -o option, your SMTP server with the -M option, and the to address (with no option). You'll then enter the subject, the text of your message, and the end-of-file character (CTRL-Z) to signal the end of the message input. Help for task 6: Be sure to replace the from address, SMTP server, and to address. java msgsend -o from@address -M SMTP.Server to@address If you are not sure of your SMTP server, contact your system administrator or check with your Internet Service Provider. Task 7: Check to make sure you received the message with your normal mail reader (Eudora, Outlook Express, pine, ...). Exercise 1. How to set up a JavaMail environment: Solution Upon successful completion, the JavaMail reference implementation will be in your CLASSPATH. Exercise 2. How to send your first message In the last exercise you sent a mail message using the demonstration program provided with the JavaMail implementation. In this exercise, you'll create the program yourself. For more help with exercises, see About the exercises on page 22 . Prerequisites: * Exercise 1. How to set up a JavaMail environment on page 22 Skeleton code: * MailExample.java Task 1: Starting with the skeleton code , get the system Properties. Help for task 1: Properties props = System.getProperties(); Task 2: Add the name of your SMTP server to the properties for the mail.smtp.host key. Fundamentals of the JavaMail API Page 23 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Help for task 2: props.put("mail.smtp.host", host); Task 3: Get a Session object based on the Properties. Help for task 3: Session session = Session.getDefaultInstance(props, null); Task 4: Create a MimeMessage from the session. Help for task 4: MimeMessage message = new MimeMessage(session); Task 5: Set the from field of the message. Help for task 5: message.setFrom(new InternetAddress(from)); Task 6: Set the to field of the message. Help for task 6: message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); Task 7: Set the subject of the message. Help for task 7: message.setSubject("Hello JavaMail"); Task 8: Set the content of the message. Help for task 8: message.setText("Welcome to JavaMail"); Task 9: Use a Transport to send the message. Help for task 9: Transport.send(message); Task 10: Compile and run the program, passing your SMTP server, from address, and to address on the command line. Fundamentals of the JavaMail API Page 24 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Help for task 10: java MailExample SMTP.Server from@address to@address Task 11: Check to make sure you received the message with your normal mail reader (Eudora, Outlook Express, pine, ...). Exercise 2. How to send your first message: Solution The following Java source file represents a solution to this exercise: * Solution/MailExample.java Exercise 3. How to check for mail In this exercise, create a program that displays the from address and subject for each message and prompts to display the message content. For more help with exercises, see About the exercises on page 22 . Prerequisites: * Exercise 1. How to set up a JavaMail environment on page 22 Skeleton Code * GetMessageExample.java Task 1: Starting with the skeleton code , get or create a Properties object. Help for task 1: Properties props = new Properties(); Task 2: Get a Session object based on the Properties. Help for task 2: Session session = Session.getDefaultInstance(props, null); Task 3: Get a Store for your e-mail protocol, either pop3 or imap. Help for task 3: Store store = session.getStore("pop3"); Task 4: Connect to your mail host's store with the appropriate username and password. Fundamentals of the JavaMail API Page 25 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Help for task 4: store.connect(host, username, password); Task 5: Get the folder you want to read. More than likely, this will be the INBOX. Help for task 5: Folder folder = store.getFolder("INBOX"); Task 6: Open the folder read-only. Help for task 6: folder.open(Folder.READ_ONLY); Task 7: Get a directory of the messages in the folder. Save the message list in an array variable named message. Help for task 7: Message message[] = folder.getMessages(); Task 8: For each message, display the from field and the subject. Help for task 8: System.out.println(i + ": " + message[i].getFrom()[0] + "\t" + message[i].getSubject()); Task 9: Display the message content when prompted. Help for task 9: System.out.println(message[i].getContent()); Task 10: Close the connection to the folder and store. Help for task 10: folder.close(false); store.close(); Task 11: Compile and run the program, passing your mail server, username, and password on the command line. Answer YES to the messages you want to read. Just hit ENTER if you don't. If you want to stop reading your mail before making your way through all the messages, enter QUIT. Help for task 11: java GetMessageExample POP.Server username password Fundamentals of the JavaMail API Page 26 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Exercise 3. How to check for mail: Solution The following Java source file represents a solution to this exercise. * Solution/GetMessageExample.java Exercise 4. How to reply to mail In this exercise, create a program that creates a canned reply message and attaches the original message if it's plain text. For more help with exercises, see About the exercises on page 22 . Prerequisites: * Exercise 3. How to check for mail on page 25 Skeleton Code: * ReplyExample.java Task 1: The skeleton code already includes the code to get the list of messages from the folder and prompt you to create a reply. Task 2: When answered affirmatively, create a new MimeMessage from the original message. Help for task 2: MimeMessage reply = (MimeMessage)message[i].reply(false); Task 3: Set the from field to your e-mail address. Task 4: Create the text for the reply. Include a canned message to start. When the original message is plain text, add each line of the original message, prefix each line with the "> " characters. Help for task 4: To check for plain text messages, check the messages MIME type with mimeMessage.isMimeType("text/plain"). Task 5: Set the message's content, once the message content is fully determined. Task 6: Send the message. Task 7: Compile and run the program, passing your mail server, SMTP server, username, password, and from address on the command line. Answer YES to the messages you want to send replies. Just hit ENTER if you don't. If you want to stop going through your mail before Fundamentals of the JavaMail API Page 27 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks making your way through all the messages, enter QUIT. Help for task 7: java ReplyExample POP.Server SMTP.Server username password from@address Task 8: Check to make sure you received the message with your normal mail reader (Eudora, Outlook Express, pine, ...). Exercise 4. How to reply to mail: Solution The following Java source file represents a solution to this exercise. * Solution/ReplyExample.java Exercise 5. How to send attachments In this exercise, create a program that sends a message with an attachment. For more help with exercises, see About the exercises on page 22 . Prerequisites: * Exercise 2. How to send your first message on page 23 Skeleton Code: * AttachExample.java Task 1: The skeleton code already includes the code to get the initial mail session. Task 2: From the session, get a Message and set its header fields: to, from, and subject. Task 3: Create a BodyPart for the main message content and fill its content with the text of the message. Help for task 3: BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setText("Here's the file"); Task 4: Create a Multipart to combine the main content with the attachment. Add the main content to the multipart. Help for task 4: Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); Fundamentals of the JavaMail API Page 28 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Task 5: Create a second BodyPart for the attachment. Task 6: Get the attachment as a DataSource. Help for task 6: DataSource source = new FileDataSource(filename); Task 7: Set the DataHandler for the message part to the data source. Carry the original filename along. Help for task 7: messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename); Task 8: Add the second part of the message to the multipart. Task 9: Set the content of the message to the multipart. Help for task 9: message.setContent(multipart); Task 10: Send the message. Task 11: Compile and run the program, passing your SMTP server, from address, to address, and filename on the command line. This will send the file as an attachment. Help for task 11: java AttachExample SMTP.Server from@address to@address filename Task 12: Check to make sure you received the message with your normal mail reader (Eudora, Outlook Express, pine, ...). Exercise 5. How to send attachments: Solution The following Java source file represents a solution to this exercise. * Solution/AttachExample.java Exercise 6. How to send HTML messages with images In this exercise, create a program that sends an HTML message with an image attachment where the image is displayed within the HTML message. Fundamentals of the JavaMail API Page 29 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks For more help with exercises, see About the exercises on page 22 . Prerequisites: * Exercise 5. How to send attachments on page 28 Skeleton code: * logo.gif * HtmlImageExample.java Task 1: The skeleton code already includes the code to get the initial mail session, create the main message, and fill its headers (to, from, subject). Task 2: Create a BodyPart for the HTML message content. Task 3: Create a text string of the HTML content. Include a reference in the HTML to an image () that is local to the mail message. Help for task 3: Use a cid URL. The content-id will need to be specified for the image later. String htmlText = "

Hello

" + ""; Task 4: Set the content of the message part. Be sure to specify the MIME type is text/html. Help for task 4: messageBodyPart.setContent(htmlText, "text/html"); Task 5: Create a Multipart to combine the main content with the attachment. Be sure to specify that the parts are related. Add the main content to the multipart. Help for task 5: MimeMultipart multipart = new MimeMultipart("related"); multipart.addBodyPart(messageBodyPart); Task 6: Create a second BodyPart for the attachment. Task 7: Get the attachment as a DataSource, and set the DataHandler for the message part to the data source. Task 8: Set the Content-ID header for the part to match the image reference specified in the HTML. Help for task 8: messageBodyPart.setHeader("Content-ID","memememe"); Task 9: Add the second part of the message to the multipart, and set the content of the Fundamentals of the JavaMail API Page 30 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks message to the multipart. Task 10: Send the message. Task 11: Compile and run the program, passing your SMTP server, from address, to address, and filename on the command line. This will send the images as an inline image within the HTML text. Help for task 11: java HtmlImageExample SMTP.Server from@address to@address filename Task 12: Check if your mail reader recognizes the message as HTML and displays the image within the message, instead of as a link to an external attachment file. Help for task 12: If your mail reader can't display HTML messages, consider sending the message to a friend. Exercise 6. How to send HTML messages with images: Solution The following Java source files represent a solution to this exercise. * Solution/logo.gif * Solution/HtmlImageExample.java Fundamentals of the JavaMail API Page 31 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Section 9. Wrapup In summary The JavaMail API is a Java package used for reading, composing, and sending e-mail messages and their attachments. It lets you build standards-based e-mail clients that employ various Internet mail protocols, including SMTP, POP, IMAP, and MIME, as well as related protocols such as NNTP, S/MIME, and others. The API divides naturally into two parts. The first focuses on sending, receiving, and managing messages independent of the protocol used, whereas the second focuses on specific use of the protocols. The purpose of this tutorial was to show how to use the first part of the API, without attempting to deal with protocol providers. The core JavaMail API consists of seven classes --Session, Message, Address, Authenticator, Transport, Store, and Folder --all of which are found in javax.mail, the top-level package for the JavaMail API. We used these classes to work through a number of common e-mail-related tasks, including sending messages, retrieving messages, deleting messages, authenticating, replying to messages, forwarding messages, managing attachments, processing HTML-based messages, and searching or filtering mail lists. Finally, we provided a number of step-by-step exercises to help illustrate the concepts presented. Hopefully, this will help you add e-mail functionality to your platform-independent Java applications. Resources You can do much more with the JavaMail API than what's found here. The lessons and exercises found here can be supplemented by the following resources: * Download the JavaMail 1.2 API from the JavaMail API home page . * The JavaBeans Activation Framework is required for versions 1.2 and 1.1.3 of the JavaMail API. * The JavaMail-interest mailing list is a Sun-hosted discussion forum for developers. * Sun's JavaMail FAQ addresses the use of JavaMail in applets and servlets, as well as prototol-specific questions. * Tutorial author John Zukowski maintains jGuru's JavaMail FAQ . * Want to see how others are using JavaMail? Check out Sun's list of third-party products. * If you want more detail about JavaMail, read Rick Grehan's "How JavaMail keeps it simple" (Lotus Developer Network, June 2000). * Benoit Marchal shows how to use Java and XML to produce plain text and HTML newsletters in this two-part series, "Managing e-zines with JavaMail and XSLT" Part 1 (developerWorks, March 2001) and Part 2 (developerWorks, April 2001). * "Linking Applications with E-mail" (Lotus Developer Network, May 2000) discusses how groupware can facilitate communication, collaboration, and coordination among applications. Fundamentals of the JavaMail API Page 32 Presented by developerWorks, your source for great tutorials ibm.com/developerWorks Feedback Please let us know whether this tutorial was helpful to you and how we could make it better. We'd also like to hear about other tutorial topics you'd like to see covered. Thanks! For questions about the content of this tutorial, contact the author John Zukowski ( jaz@zukowski.net ) Colophon This tutorial was written entirely in XML, using the developerWorks Toot-O-Matic tutorial generator. The Toot-O-Matic tool is a short Java program that uses XSLT stylesheets to convert the XML source into a number of HTML pages, a zip file, JPEG heading graphics, and PDF files. Our ability to generate multiple text and binary formats from a single source file illustrates the power and flexibility of XML. Fundamentals of the JavaMail API Page 33
Visual.Basic.2010.&.NET4.高级编程(第6版)-文字版.pdf 第I部分 语言结构和环境 第1章 visual studio 2010 3 1.1 visual studio 2010:从express到ultimate的各种版本 4 1.2 visual basic的关键字和语法 7 1.2.1 控制台应用程序 10 1.2.2 从项目模板上创建项目 11 1.2.3 solution explorer窗口 13 1.2.4 项目属性 14 1.2.5 assembly information屏幕 15 1.2.6 编译设置 16 1.2.7 调试属性 20 1.2.8 引用 21 1.2.9 资源 23 1.2.10 设置 24 1.2.11 其他项目属性选项卡 26 1.3 provb_vs2010项目 27 1.3.1 在代码中设置窗体属性 29 1.3.2 visual studio的其他组件 37 1.4 增强示例应用程序的功能 37 1.4.1 定制代码 39 1.4.2 构建应用程序 43 1.4.3 重用第一个windows窗体 50 1.5 visual studio 2010中的特色功能 51 1.5.1 构建配置 51 1.5.2 任务列表 53 1.5.3 command窗口 54 1.5.4 server explorer 54 1.5.5 在visual studio 2010中记录和使用宏 55 1.5.6 类图 57 1.5.7 应用程序生命周期管理 58 1.5.8 性能工具 60 1.6 小结 62 第2章 对象和visual basic 63 2.1 面向对象的术语 64 2.1.1 对象、类和实例 64 2.1.2 对象的组成 65 2.1.3 system.object 68 2.2 使用visual basic类型 68 2.2.1 值类型和引用类型 69 2.2.2 基本类型 71 2.3 命令:条件语句 72 2.3.1 if then 73 2.3.2 比较运算符 73 2.3.3 select case 75 2.4 值类型(结构) 75 2.4.1 布尔类型 76 2.4.2 整数类型 77 2.4.3 无符号类型 78 2.4.4 小数类型 78 2.4.5 char和byte类型 81 2.4.6 datetime类型 81 2.5 引用类型(类) 82 2.5.1 object类 82 2.5.2 string类 83 2.5.3 xml字面量 87 2.5.4 dbnull类和isdbnull()函数 89 2.6 参数传递 89 2.7 变量的作用域 91 2.8 使用对象 92 2.8.1 对象的声明和实例化 92 2.8.2 对象引用 93 2.8.3 取消对象的引用 93 2.8.4 前期绑定与后期绑定 94 2.9 数据类型转换 95 2.10 创建类 100 2.10.1 类 100 2.10.2 事件的处理 110 2.10.3 处理多个事件 111 2.10.4 withevents关键字 111 2.10.5 触发事件 111 2.10.6 声明和触发定制事件 112 2.10.7 用withevents关键字接收事件 113 2.10.8 用addhandler接收事件 115 2.10.9 构造函数方法 116 2.10.10 终止和清除 117 2.11 高级概念 118 2.11.1 重载方法 119 2.11.2 重载构造函数方法 121 2.11.3 共享方法、变量和事件 122 2.11.4 运算符重载 127 2.11.5 委托 129 2.11.6 类和组件 133 2.11.7 lambda表达式 134 2.12 小结 135 第3章 定制对象 137 3.1 继承 138 3.1.1 继承的实现 139 3.1.2 继承的层次 157 3.1.3 与基类、类及对象交互 159 3.1.4 构造函数 164 3.1.5 protected作用域 169 3.1.6 事件与继承 171 3.1.7 共享方法 174 3.1.8 共享事件 176 3.1.9 创建抽象基类 176 3.2 多接口 178 3.2.1 对象接口 178 3.2.2 辅助接口 180 3.3 抽象性 185 3.4 封装性 188 3.5 多态性 190 3.5.1 方法签名 190 3.5.2 实现多态性 191 3.6 进一步讨论继承 200 3.7 小结 211 第4章 公共语言运行库 213 4.1 .net应用程序的组成元素 214 4.1.1 模块 214 4.1.2 程序集 215 4.1.3 类型 215 4.2 版本化与部署 216 4.2.1 对版本化更好的支持 216 4.2.2 major.minor.build.revision版本介绍 217 4.2.3 更好的部署 217 4.3 跨语言集成 218 4.3.1 通用类型系统 218 4.3.2 元数据 219 4.3.3 对元数据更好的支持 219 4.3.4 属性 220 4.3.5 reflection api 222 4.4 il反汇编程序 222 4.5 内存管理 223 4.5.1 传统的垃圾回收机制 223 4.5.2 更快地为对象分配内存 230 4.5.3 垃圾回收器的优化 231 4.6 名称空间 232 4.6.1 名称空间的概念 233 4.6.2 名称空间与引用 236 4.6.3 常用的名称空间 237 4.6.4 导入名称空间并指定别名 239 4.6.5 为名称空间指定别名 240 4.6.6 在asp.net中引用名称空间 241 4.7 创建自己的名称空间 241 4.8 my关键字 244 4.8.1 my.application名称空间 244 4.8.2 my.computer名称空间 248 4.8.3 my.forms名称空间 251 4.8.4 my.resources名称空间 251 4.8.5 my.user名称空间 251 4.8.6 my.webservices名称空间 251 4.9 扩展my名称空间 252 4.10 小结 254 第5章 用visual basic进行声明式编程 255 5.1 声明式编程与visual basic 256 5.2 使用xaml创建窗口 257 5.3 xaml语法 260 5.3.1 xaml语言基础 261 5.3.2 使用xaml声明工作流 264 5.4 小结 265 第6章 异常处理和调试 267 6.1 visual studio 2010 team system的新增内容:历史调试 267 6.2 与visual basic 6兼容的注意事项 268 6.3 .net中的异常处理 268 6.4 结构化异常处理的关键字 269 6.4.1 try、catch和finally关键字 270 6.4.2 throw关键字 271 6.4.3 抛出新的异常 272 6.4.4 exit try语句 273 6.4.5 嵌套的try结构 274 6.4.6 异常属性的使用 275 6.4.7 message属性 276 6.4.8 innerexception和targetsite属性 276 6.5 与visual basic 6样式的错误处理交互操作 280 6.6 记录错误 281 6.6.1 事件日志 281 6.6.2 事件、方法和属性 282 6.6.3 写入跟踪文件 284 6.7 小结 286 第7章 测试驱动的开发 287 7.1 测试的内容和方式 288 7.2 visual studio中的tdd工具 290 7.3 单元测试过程 291 7.3.1 创建测试程序 291 7.3.2 运行测试程序 294 7.3.3 测试数据访问代码 295 7.3.4 使用generate from usage特性 302 7.4 其他visual studio版本 306 7.5 第三方测试框架 306 7.6 小结 307 第ii部分 业务对象和数据访问第8章 数组、集合和泛型 311 8.1 数组 312 8.1.1 多维数组 313 8.1.2 ubound函数 314 8.1.3 redim语句 314 8.1.4 preserve关键字 315 8.2 集合 315 8.2.1 循环语句 317 8.2.2 装箱 319 8.3 泛型 320 8.3.1 泛型的使用 321 8.3.2 nullable类型 322 8.3.3 泛型类型 323 8.3.4 泛型方法 326 8.4 创建泛型 327 8.4.1 泛型类型 328 8.4.2 泛型方法 334 8.4.3 约束 335 8.4.4 泛型和后期绑定 338 8.4.5 协变和逆变 339 8.5 小结 340 第9章 在vb中使用xml 341 9.1 xml简介 342 9.2 xml序列化 343 9.3 system.xml文档支持 348 9.4 xml流样式分析程序 348 9.4.1 写入xml流 349 9.4.2 读取xml流 352 9.4.3 文档对象模型(dom) 360 9.5 xslt转换 364 9.5.1 使用xslt转换不同的xml标准 367 9.5.2 system.xml.xsl中定义的其他类和接口 370 9.6 asp.net中的xml 370 9.6.1 xmldatasource服务器控件 370 9.6.2 xmldatasource控件的名称空间问题 374 9.6.3 xml服务器控件 375 9.7 linq to xml 376 9.8 linq to xml帮助对象 376 9.8.1 xdocument对象 377 9.8.2 xelement对象 377 9.8.3 xnamespace对象 378 9.8.4 xattribute对象 380 9.9 visual basic和xml字面量 381 9.10 使用linq查询xml文档 382 9.10.1 查询静态的xml文档 382 9.10.2 查询动态的xml文档 384 9.11 处理xml文档 385 9.11.1 读取xml文档 385 9.11.2 写入xml文档 386 9.12 vb中的lambda表达式 387 9.13 小结 389 第10章 ado.net和linq 391 10.1 ado.net的体系结构 392 10.2 ado.net的基本功能 393 10.2.1 ado.net的常见任务 393 10.2.2 ado.net的基本名称空间和类 398 10.2.3 ado.net组件 399 10.3 .net数据提供程序 400 10.3.1 connection对象 400 10.3.2 command对象 401 10.3.3 通过command对象使用存储过程 402 10.3.4 datareader对象 405 10.3.5 命令的异步执行 407 10.3.6 dataadapter对象 409 10.3.7 sql server .net数据提供程序 413 10.3.8 ole db .net数据提供程序 413 10.4 dataset组件 413 10.4.1 datatablecollection对象 414 10.4.2 datarelationcollection对象 414 10.4.3 extendedproperties属性 414 10.4.4 创建和使用dataset对象 415 10.4.5 ado.net的datatable对象 417 10.4.6 dataset和datatable对象的高级ado.net特性 418 10.5 使用通用提供程序模型 420 10.6 ado.net中的连接池 422 10.7 transactions类和system.transactions名称空间 423 10.7.1 创建事务 423 10.7.2 创建资源管理器 425 10.8 linq to sql 425 10.9 linq to sql和visual basic 426 10.9.1 用linq to sql提取数据:创建控制台应用程序 426 10.9.2 o/r设计器 427 10.9.3 创建product对象 428 10.10 对象到linq对象的映射 429 10.10.1 datacontext对象 430 10.10.2 table(tentity)对象 432 10.11 查询数据库 433 10.11.1 使用查询表达式 433 10.11.2 查询表达式详述 433 10.11.3 用表达式过滤 434 10.11.4 联接 434 10.11.5 数据项的组合 435 10.12 存储过程 437 10.13 更新数据库 438 10.14 小结 440 第11章 使用entity framework访问数据 441 11.1 对象关系映射 441 11.2 entity framework体系结构 442 11.2.1 概念模型 443 11.2.2 存储模型 446 11.2.3 映射模型 447 11.2.4 linq to entities 448 11.2.5 objectcontext 449 11.3 把对象映射到实体上 451 11.3.1 简单映射 451 11.3.2 对多个对象使用一个表 453 11.3.3 对一个对象使用多个表 455 11.4 从模型中生成数据库 457 11.5 小结 460 第12章 使用sql server 461 12.1 sql server compact 462 12.1.1 连接sql server compactedition数据库 463 12.1.2 同步数据 466 12.2 sql server内置的xml功能 472 12.3 sql server中的clr集成 474 12.3.1 决定使用t-sql还是vb 475 12.3.2 创建用户定义的类型 475 12.3.3 创建存储过程 487 12.3.4 在sql server中使用web服务 493 12.3.5 sql server 2008特性 498 12.4 wcf数据服务 499 12.4.1 rest 499 12.4.2 atom和json 499 12.4.3 使用wcf数据服务提供数据 500 12.4.4 wcf数据服务的客户端库 504 12.5 小结 508 第13章 服务(xml/wcf) 509 13.1 服务 510 13.1.1 网络角度 510 13.1.2 应用程序的发展 510 13.1.3 合并网络和应用程序开发 510 13.1.4 web服务基础 511 13.1.5 存在的问题 512 13.1.6 其他技术 512 13.1.7 web服务 513 13.1.8 组合起来 514 13.1.9 wcf服务的构成 514 13.2 向soa迈出一大步 515 13.2.1 wcf的功能 516 13.2.2 协定和元数据 516 13.2.3 使用ws-*协议 517 13.3 建立wcf服务 518 13.4 建立wcf使用者应用程序 524 13.4.1 添加服务引用 525 13.4.2 查看引用 526 13.4.3 配置文件的修改 529 13.4.4 编写使用者应用程序的代码 531 13.5 使用数据协定 533 13.6 名称空间 535 13.6.1 建立主机应用程序 535 13.6.2 建立使用者应用程序 536 13.6.3 查看hellocustomerservice的wsdl和架构 538 13.7 小结 540 第iii部分 智能客户端应用程序第14章 windows窗体 543 14.1 system.windows.forms名称空间 543 14.2 窗体的使用 544 14.2.1 设置启动窗体 544 14.2.2 通过sub main显示窗体 545 14.2.3 application类的更多内容 545 14.2.4 窗体的启动位置 545 14.2.5 窗体边框 545 14.2.6 始终置顶——topmost属性 546 14.2.7 附属窗体 546 14.2.8 改变窗体的透明度 547 14.2.9 可视化继承 549 14.2.10 滚动窗体 549 14.2.11 mdi窗体 549 14.2.12 vb 2010中的mdi样例 550 14.2.13 对话框窗体 551 14.2.14 运行时的窗体 553 14.2.15 默认的窗体实例 554 14.3 控件 554 14.3.1 以tab键切换控件的顺序 554 14.3.2 所有控件的属性 555 14.3.3 动态调整控件的大小和布局 555 14.3.4 flowlayoutpanel控件 557 14.3.5 tablelayoutpanel控件 558 14.3.6 panel和groupbox容器控件 559 14.3.7 扩展的provider控件 560 14.3.8 数据输入的高级功能 562 14.3.9 验证数据输入 564 14.3.10 工具栏与toolstrip控件 565 14.3.11 菜单 568 14.3.12 通用对话框 569 14.3.13 拖放操作 571 14.3.14 标准windows窗体控件小结 573 14.3.15 处理相关控件组 575 14.3.16 在运行时添加控件 576 14.4 其他编程技巧 577 14.5 小结 577 第15章 windows窗体的高级功能 579 15.1 在可视化控件中封装逻辑 579 15.2 在windows窗体中开发自定义的控件 580 15.2.1 继承现有的控件 580 15.2.2 构建复合控件 580 15.2.3 从头编写控件 581 15.3 继承现有的控件 581 15.3.1 基本步骤 581 15.3.2 给派生的控件添加代码 581 15.3.3 其他有用的特性 584 15.3.4 为派生的控件自定义事件 585 15.3.5 限制选中项数的checkedlistbox 586 15.4 control与usercontrol基类 589 15.4.1 control类 589 15.4.2 usercontrol类 589 15.5 复合控件 590 15.5.1 创建复合的user-control 591 15.5.2 改变控件的大小 591 15.5.3 提供子控件的属性 592 15.5.4 一个具体的例子 592 15.6 从头构建控件 595 15.7 给工具箱中的控件添加图标 600 15.8 在控件中嵌入其他控件 601 15.9 小结 602 第16章 集成wpf和windows 窗体的用户控件 605 16.1 集成库 606 16.2 在windows窗体中包含wpf控件 607 16.2.1 创建wpf控件库 608 16.2.2 windows窗体应用程序 610 16.3 在wpf中包含windows 窗体控件 616 16.4 集成的限制 621 16.5 小结 622 第17章 wpf桌面应用程序 623 17.1 内容、位置、原因、方式——wpf策略 624 17.2 光栅图形和矢量图形 625 17.3 下一个windows项目应使用wpf吗 625 17.4 创建wpf应用程序 626 17.4.1 实现定制的wpf应用程序 627 17.4.2 定制用户界面 639 17.4.3 定制按钮 647 17.4.4 wpf用户控件 651 17.5 小结 672 第18章 expression blend 3 675 18.1 了解blend 676 18.2 sketchflow 682 18.2.1 第一个sketchflow 682 18.2.2 sketchflow player 685 18.2.3 归档sketchflow 686 18.3 小结 686 第19章 silverlight 687 19.1 什么是silverlight 687 19.1.1 smooth streaming特性 688 19.1.2 业界标准视频 688 19.1.3 数字版权管理 688 19.2 启动silverlight项目 688 19.2.1 silverlight应用程序 689 19.2.2 silverlight导航应用程序 689 19.2.3 silverlight类库 690 19.3 silverlight解决方案 691 19.3.1 web应用程序 691 19.3.2 应用程序库缓存 691 19.3.3 silverlight应用程序 692 19.4 控件 695 19.5 给silverlight项目添加项 702 19.5.1 silverlight用户控件 703 19.5.2 silverlight应用程序类 703 19.5.3 silverlight页面 703 19.5.4 silverlight子窗口 703 19.5.5 silverlight模板控件 703 19.5.6 silverlight资源字典 704 19.6 浏览器之外的silverlight 704 19.7 小结 705 第iv部分 internet应用程序技术 第20章 silverlight和服务 709 20.1 服务和silverlight 709 20.1.1 asmx web服务 709 20.1.2 wcf服务 712 20.1.3 ado.net数据服务 716 20.2 model-view-viewmodel 725 20.2.1 分割 725 20.2.2 model 725 20.2.3 view 728 20.2.4 viewmodel 729 20.3 小结 729 第21章 使用asp.net 731 21.1 asp.net的历史 731 21.2 asp.net的重要特性 732 21.2.1 开发效率 732 21.2.2 性能和可伸缩性 732 21.2.3 本地化 732 21.2.4 健康监控 733 21.2.5 易于访问数据 733 21.2.6 管理和维护 733 21.3 visual studio对asp.net 的支持 733 21.3.1 web site和web application项目 733 21.3.2 asp.net应用程序文件夹 734 21.3.3 web服务器选项 735 21.4 用web窗体构建asp.net应用程序 735 21.5 数据驱动的应用程序 746 21.5.1 使用sqldatasource控件绑定数据 746 21.5.2 使用linqdatasource控件绑定数据 754 21.5.3 使用objectdastasource控件绑定数据 757 21.6 小结 759 第22章 asp.net的高级功能 761 22.1 母版页 761 22.1.1 创建母版页 762 22.1.2 创建内容页 765 22.1.3 为母版页提供默认内容 767 22.2 导航 767 22.2.1 使用sitemappath服务器控件 769 22.2.2 menu服务器控件 770 22.3 使用asp.net的提供程序模型 771 22.4 成员和角色管理 776 22.5 配置文件属性 781 22.6 microsoft ajax(asp.net ajax) 783 22.6.1 理解对ajax的需求 783 22.6.2 microsoft ajax 的实现 784 22.6.3 updatepanel控件和客户端服务调用 785 22.6.4 示例项目 785 22.6.5 添加updatepanel控件 789 22.6.6 使用客户端服务调用和客户端模板 790 22.7 小结 795 第23章 asp.net mvc 797 23.1 mvc和asp.net 798 23.2 构建asp.net mvc应用程序 798 23.2.1 创建项目 798 23.2.2 控制器和操作 800 23.2.3 添加模型 802 23.2.4 视图 804 23.2.5 路由 807 23.2.6 搭框架和crud操作 808 23.2.7 验证 815 23.3 小结 817 第24章 sharepoint 2010开发 819 24.1 简介 819 24.1.1 sharepoint foundation 2010 820 24.1.2 sharepoint server 2010 820 24.1.3 sharepoint的术语 820 24.1.4 sharepoint开发环境 821 24.2 feature和solution framework 821 24.2.1 feature 821 24.2.2 solution framework 829 24.3 用于sharepoint开发的visual studio工具 833 24.4 sharepoint 2010对象模型 839 24.4.1 服务器对象模型 840 24.4.2 客户端对象模型 843 24.5 构建web 部件 845 24.6 小结 851 第v部分 库和专业主题技术 第25章 visual studio tools foroffice 855 25.1 vsto的各个版本 856 25.1.1 office的自动化功能和vsto 856 25.1.2 免pia部署 856 25.1.3 vsto项目类型 857 25.2 office业务应用程序的体系结构 858 25.3 使用vba和vsto 859 25.4 创建文档模板(word) 864 25.4.1 给文档添加内容 866 25.4.2 添加ribbon和操作窗格 867 25.4.3 激活操作窗格 870 25.4.4 更新内容控件 872 25.5 创建office插件(excel) 875 25.6 outlook form regions 881 25.7 小结 889 第26章 windows workflow foundation 891 26.1 应用程序中的工作流 891 26.2 建立工作流 892 26.2.1 用windows workflowfoundation添加工作流 892 26.2.2 一个简单的工作流 894 26.2.3 标准活动 897 26.2.4 一个不太简单的工作流 899 26.2.5 建立定制活动 907 26.2.6 动态加载工作流 911 26.3 重新构建工作流设计器 912 26.4 小结 915 第27章 本地化 917 27.1 文化和区域 917 27.1.1 理解文化类型 918 27.1.2 线程 919 27.1.3 在asp.net中声明全局文化 921 27.1.4 在asp.net中使用文化设置 922 27.2 转换数值和操作 923 27.2.1 理解日期之间的区别 923 27.2.2 理解数字和货币的区别 925 27.2.3 理解排序字符串的区别 927 27.3 asp.net资源文件 929 27.3.1 使用本地资源 929 27.3.2 全局资源 933 27.4 windows窗体中的资源文件 935 27.5 小结 938 第28章 与com的交互操作 939 28.1 理解com 940 28.2 com和.net的交互 940 28.2.1 传统的组件 941 28.2.2 .net应用程序 942 28.2.3 调试 945 28.2.4 直接使用tlbimp 945 28.2.5 后期绑定 946 28.3 activex控件 950 28.3.1 传统的activex控件 950 28.3.2 另一个.net应用程序 952 28.3.3 再次调试 954 28.4 在com应用程序中使用.net组件 954 28.4.1 .net组件 954 28.4.2 regasm 956 28.4.3 tlbexp 957 28.5 p/invoke 957 28.6 小结 957 第29章 网络编程 959 29.1 协议、地址和端口 959 29.1.1 地址与计算机名 961 29.1.2 端口:指定应用程序 961 29.1.3 防火墙:不离不弃 962 29.2 system.net名称空间 963 29.2.1 web请求与响应 963 29.2.2 使用webclient简化常用的web请求 969 29.3 套接字 970 29.3.1 构建应用程序 971 29.3.2 创建conversation窗口 973 29.3.3 发送消息 980 29.3.4 关闭应用程序 984 29.4 在应用程序中使用internetexplorer 988 29.5 小结 991 第30章 应用程序服务 993 30.1 给应用程序服务使用iis 993 30.2 windows服务 993 30.3 windows服务的特性 994 30.4 与windows服务交互 995 30.5 创建windows服务 996 30.5.1 用于windows服务的.net framework类 996 30.5.2 其他类型的windows服务 998 30.6 在vb中创建windows服务 998 30.7 创建文件监视器服务 1000 30.7.1 创建windows服务的解决方案 1000 30.7.2 给服务添加.net组件 1000 30.7.3 安装服务 1003 30.7.4 启动服务 1004 30.7.5 卸载服务 1005 30.8 与服务通信 1005 30.8.1 servicecontroller类 1006 30.8.2 把servicecontroller集成到例子中 1007 30.8.3 servicecontroller的更多内容 1008 30.9 定制命令 1008 30.10 给服务传递字符串 1010 30.11 调试服务 1010 30.12 小结 1012 第31章 程序集和反射 1013 31.1 程序集 1013 31.2 清单 1014 31.2.1 程序集标识部分 1016 31.2.2 引用的程序集 1018 31.3 程序集与部署 1018 31.3.1 应用程序私有的程序集 1018 31.3.2 共享程序集 1019 31.4 版本化问题 1020 31.4.1 应用程序隔离 1020 31.4.2 并行执行 1020 31.4.3 自描述 1021 31.4.4 版本策略 1021 31.4.5 配置文件 1022 31.5 反射基础 1025 31.5.1 assembly类 1026 31.5.2 获得当前加载的程序集 1026 31.5.3 type类 1027 31.6 程序集的动态加载 1028 31.6.1 assembly类的loadfrom方法 1028 31.6.2 动态加载示例 1029 31.6.3 传入程序集 1030 31.7 小结 1031 第32章 .net framework中的安全性 1033 32.1 安全的概念与定义 1034 32.2 system.security.permissions名称空间中的权限 1035 32.2.1 代码访问权限 1037 32.2.2 身份权限 1038 32.2.3 基于角色的权限 1038 32.3 管理代码访问权限集合 1041 32.4 用户访问控制 1043 32.5 定义应用程序的uac设置 1043 32.5.1 安全性工具 1045 32.5.2 使用securityexception类处理异常 1046 32.6 加密基础 1047 32.7 小结 1060 第33章 使用任务和线程进行并行编程 1061 33.1 启动并行任务 1061 33.1.1 system.threading.tasks.parallel类 1062 33.1.2 parallel.invoke 1062 33.2 把串行代码转换为并行代码 1066 33.2.1 检测热点 1067 33.2.2 测试并行执行获得的速度提升 1069 33.2.3 理解并行和并发执行 1070 33.3 并行循环 1071 33.3.1 parallel.for 1071 33.3.2 parallel.foreach 1076 33.3.3 退出并行循环 1081 33.4 指定希望的并行度 1086 33.4.1 paralleloptions 1086 33.4.2 理解硬件线程和逻辑核心 1087 33.5 创建和管理任务 1088 33.5.1 system.threading.tasks.task 1089 33.5.2 理解任务的生命周期 1090 33.5.3 使用任务并行化代码 1091 33.5.4 从任务中返回值 1099 33.5.5 为并发和并行准备代码 1102 33.5.6 理解并发集合特性 1103 33.5.7 把linq转换为plinq 1106 33.6 小结 1108 第34章 部署 1109 34.1 应用程序部署 1110 34.1.1 .net中的部署很简单 1110 34.1.2 xcopy部署 1110 34.1.3 使用windows installer 1110 34.1.4 clickonce部署 1111 34.2 选择framework版本 1111 34.3 visual studio部署项目 1112 34.3.1 项目模板 1112 34.3.2 创建部署项目 1113 34.4 修改部署项目 1117 34.4.1 项目属性 1117 34.4.2 file system编辑器 1119 34.4.3 registry编辑器 1122 34.4.4 file types编辑器 1124 34.4.5 user interface编辑器 1125 34.4.6 custom actions编辑器 1127 34.4.7 launch conditions编辑器 1129 34.4.8 构建 1132 34.5 windows应用程序的internet部署 1132 34.5.1 “无接触”部署 1132 34.5.2 clickonce部署 1133 34.6 iis web部署工具 1140 34.7 小结 1142 第vi部分 附 录 附录 a vb编译器 1145 附录 b visual basic powerpacks tools 1161 附录 c workflow 2008 1173 附录 d 企业服务 1193 附录 e 云的编程 1215

3,242

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 SharePoint
社区管理员
  • SharePoint社区
  • 霖雨
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧